import React from 'react'
import { useSelector, useDispatch } from 'react-redux';
import { addNum, addgoods, initschoollistAsync } from '../store-rtk/modules/shopSlice';
import { addCount, addAge } from '../store-rtk/modules/userSlice';
import { useEffect } from 'react'
type Props = {}

interface stateType {
    user: {
        count: number,
        userinfo: {
            username: string,
            age: number
        }
    },
    shop: {
        num: number,
        goodsArr: Array<{
            id: number,
            proname: string,
            price: number
        }>
        schoollist: Array<{
            id: number,
            school_name: string
        }>
    }
}
export default function Father1({ }: Props) {
    const { user, shop } = useSelector((state: stateType) => state)
    console.log('shop', shop);
    const dispatch = useDispatch()
    useEffect(() => {
        dispatch(initschoollistAsync())
    }, [])
    return (
        <div>
            {/* shop 数据 */}
            <p onClick={() => {
                dispatch(addNum())
            }}>num:{shop.num}</p>
            <ul>
                {
                    shop.goodsArr.map(item => <li key={item.id}>{item.proname}</li>)
                }
            </ul>
            <ul>
                {
                    shop.schoollist.map((item) => <li key={item.id}>{item.school_name}</li>)
                }
            </ul>
            {/* user数据 */}
        </div>
    )
}